﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SuperSearch
{
    public partial class Settings : Form
    {
        public Settings()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (var lang in Enum.GetNames(typeof(Google.API.Language)))
            {
                comboBoxSource.Items.Add(lang);
                comboBoxDest.Items.Add(lang);
            }
            MakeChanges();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Save();
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Reload();
            Close();
        }

        private void MakeChanges()
        {
            textBoxDomain.Enabled = radioButtonManualProxyConfig.Checked;
            textBoxProxyAdress.Enabled = radioButtonManualProxyConfig.Checked;
            textBoxProxyPassword.Enabled = radioButtonManualProxyConfig.Checked;
            textBoxProxyUserName.Enabled = radioButtonManualProxyConfig.Checked;
            numericUpDownProxyPort.Enabled = radioButtonManualProxyConfig.Checked;

            comboBoxSource.Enabled = !checkBoxAutoDetectLanguage.Checked;
        }

        private void radioButtonNoProxy_CheckedChanged(object sender, EventArgs e)
        {
            MakeChanges();
        }

        private void radioButtonManualProxyConfig_CheckedChanged(object sender, EventArgs e)
        {
            MakeChanges();
        }

        private void checkBoxAutoDetectLanguage_CheckedChanged(object sender, EventArgs e)
        {
            MakeChanges();
        }
    }
}
